package leetcode.jianzhioffer;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-10-28 15:55
 **/
public class JianZhiOffer50 {

    public char firstUniqChar(String s) {
        Map<Character, Integer> map = new LinkedHashMap<>();
        int len = s.length();
        for (int i = 0; i < len; i++) {
            map.put(s.charAt(i), map.getOrDefault(s.charAt(i),0) + 1);
        }

        Set<Map.Entry<Character,Integer>> set = map.entrySet();
        for (Map.Entry<Character,Integer> entry : set) {
            if (entry.getValue() == 1) {
                return entry.getKey();
            }
        }
        return ' ';

    }

}
